<template>
  <div>
    <TreeList
      ref="treeList"
      :operationList="operationList"
      :showTree="true"
      :columns="columns"
      :treeUrl="treeUrl"
      :treeData="treeData"
      :treeMap="treeMap"
      :listUrl="listUrl"
      :listData="listData"
      :disabledDrag="false"
      :fixedSort="false"
      :fixedSelection="false"
      :rules="rules"
      :searchList="searchList"
      @on-list="onList">
    </TreeList>
  </div>
</template>
<script>
import TreeList from '@/page/business/inline-tree-list'
import searchList from './search-conf'
import operationList from './operation-conf'
import {columns} from './table'
export default {
  data () {
    return {
      operationList: [],
      searchList: [],
      treeUrl: '.${extParam.REQUEST_PREFIX!}/${module.name ? uncap_first}treeList',
      listUrl: '.${extParam.REQUEST_PREFIX!}/${module.name ? uncap_first}',
      treeData: {},
      columns: [],
      treeMap: {
        id: '${module.pkField.name}'
      },
      listData: {}
    }
  },
  components: {
    TreeList
  },
  provide () {
    return {
      changeEdit: this.changeEdit,
      /*拖拽排序, disabledDrag为true时生效*/
      setSortIndex: this.setSortIndex,
      /*表格扩展*/
      expandParent: this.expandParent,
      /*保存*/
      changeSave: this.changeSave,
      /*过滤编辑按钮*/
      filterEdit: this.filterEdit,
      /*过滤删除按钮*/
      filterDelete: this.filterDelete,
      /*断言删除*/
      assertDelete: this.assertDelete,
      changeCancel () {},
      changeAdd: this.changeAdd
    }
  },
  created () {
    this.searchList = searchList.call(this)
    this.operationList = operationList.call(this)
    this.columns = columns
    this.rules = {
      <#list module.requiredFields as field>
      <#if (field.constraint)?? && field.constraint.required>
      ${field.name}: [
        {required: true, message: '${field.explain}项必填', trigger: 'blur'}
      ]<#if field_has_next>,</#if>
      </#if>
      </#list>
    }
  },
  mounted () {
    setTimeout(() => {
      //
    }, 1000)
  },
  methods: {
    dropChange () {},
    add () {},
    onList () {
      /*获取列表数据*/
    },
    setSortIndex () {
      this.$refs.treeList.forceRender()
    },
    expandParent () {
      /*调取列表刷新方法*/
      this.$refs.treeList.forceRender()
    },
    /*编辑按钮触发*/
    changeEdit () {},
    /*保存按钮触发*/
    changeSave () {
      return new Promise((resolve, reject) => {
        resolve()
      })
    },
    /*断言删除*/
    assertDelete () {
      return new Promise((resolve, reject) => {
        resolve(/*传入删除参数*/)
      })
    },
    changeAdd (item) {},
    /*过滤删除*/
    filterDelete () {
      return true
    },
    /*过滤编辑*/
    filterEdit () {
      return true
    }
  }
}
</script>
<style lang="scss" scoped>

</style>